﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
using Campus.Main.Basic.Settings;
using Campus.Report.ReportForm;
using Microsoft.Office.Interop.Word;
using Microsoft.Reporting.WinForms;
using cpmntctrl;
using dbcntn;

namespace Campus.Main.Basic
{
    public partial class KKayit : Kayit
    {
        public KKayit():base()
        {
            InitializeComponent();
            id = "";
            txt_student_id.Leave += TextBox3Leave;
        }

        public KKayit(string ID):base(2)
        {
            InitializeComponent();
            id = ID;
        }

        private string id;
        private int _alerji = 0;
        private int _hasta = 0;
        private string _alerjiDesc = "Yok";
        private string _hastaDesc = "Yok";
        private int _sigara = 0;
        private int prev;
        private int next;
        private int max;
        private int min;

        #region Method

        protected override void Set(string studentid,string tablename)
        {
            string id = AToDb.SelectField(tablename, "ID_student", "student_id", "'"+studentid+"'");
            if (AToDb.SelectField(tablename, "student_id", "ID_student", id).Length > 0)
            {

                dtp_enterdate.Text = AToDb.SelectField(tablename, "enter_date", "id_student", id);


                txt_dosye_no.Text = id ;
                txt_name.Text = AToDb.SelectField(tablename, "name", "ID_student", id);
                txt_student_id.Text = AToDb.SelectField(tablename, "student_id", "ID_student", id);
                txt_no.Text = AToDb.SelectField(tablename, "no", "ID_student", id);
                maskedTextBox1.Text = Helper.ChangeDateFormat(AToDb.SelectField(tablename, "cast(date(birth_date) as char)", "ID_student", id)).ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);

                txt_birth_place.Text = AToDb.SelectField(tablename, "birth_place", "id_student", id);
                txt_phone_number.Text = AToDb.SelectField(tablename, "home_telephone", "id_student", id);
                txt_home_address.Text = AToDb.SelectField(tablename, "home_address", "id_student", id);
                cmb_nation.SelectedValue = AToDb.SelectField(tablename, "nation_id", "id_student", id);
                cmb_country.SelectedValue = AToDb.SelectField(tablename, "country_id", "id_student", id);
                string bolum = AToDb.SelectField(tablename, "bolum_id", "id_student", id);
                cmb_fakulty.SelectedValue =
                    AToDb.SelectField("select fakulty_id from bolum where id=" +
                                      bolum);
                cmb_bolum.SelectedValue = bolum; //aToDb.SelectField("onmaintable", "bolum_id", "id_student", id);
                cmb_cource.SelectedValue = AToDb.SelectField(tablename, "cource_id", "id_student", id);
                txt_passport.Text = AToDb.SelectField(tablename, "passport", "id_student", id);
                cmb_place.SelectedValue = AToDb.SelectField(tablename, "place_id", "id_student", id);
                cmb_sex.SelectedValue=pol=pol = Int32.Parse(AToDb.SelectField(tablename, "pol_id", "id_student", id));
                txt_dad_name.Text = AToDb.SelectField(tablename, "dad_name", "id_student", id);

                txt_dad_surname.Text = AToDb.SelectField(tablename, "dad_surname", "id_student", id);
                cmb_dad_profession.SelectedValue = AToDb.SelectField(tablename, "dad_profession", "id_student", id);
                txt_dad_phone.Text = AToDb.SelectField(tablename, "dad_workphone", "id_student", id);
                txt_dad_address.Text = AToDb.SelectField(tablename, "dad_workaddress", "id_student", id);
                txt_dad_zarplata.Text = AToDb.SelectField(tablename, "dad_income", "id_student", id);
                cmb_dad_valute.SelectedValue = AToDb.SelectField(tablename, "valute_idd", "id_student", id);
                cmb_dad_health.SelectedValue = AToDb.SelectField(tablename, "dad_health_id", "id_student", id);
                cmb_dad_handicap.SelectedValue = AToDb.SelectField(tablename, "dad_handicap_id", "id_student", id);

                txt_mom_name.Text = AToDb.SelectField(tablename, "mom_name", "id_student", id);
                txt_mom_surname.Text = AToDb.SelectField(tablename, "mom_surname", "id_student", id);
                cmb_mom_profession.SelectedValue = AToDb.SelectField(tablename, "mom_profession", "id_student", id);
                txt_mom_phone.Text = AToDb.SelectField(tablename, "mom_workphone", "id_student", id);
                txt_mom_address.Text = AToDb.SelectField(tablename, "mom_workaddress", "id_student", id);
                txt_mom_zarplata.Text = AToDb.SelectField(tablename, "mom_income", "id_student", id);
                cmb_mom_valute.SelectedValue = AToDb.SelectField(tablename, "valute_idm", "id_student", id);
                cmb_mom_health.SelectedValue = AToDb.SelectField(tablename, "mom_health_id", "id_student", id);
                cmb_mom_handicap.SelectedValue = AToDb.SelectField(tablename, "mom_handicap_id", "id_student", id);

                cmb_parent_state.SelectedValue = AToDb.SelectField(tablename, "parent_state", "id_student", id);
                cmb_count.SelectedValue = AToDb.SelectField(tablename, "studyfamilycount", "id_student", id);
                cmb_student_handicap.SelectedValue = AToDb.SelectField(tablename, "handicap_id", "id_student", id);

                txt_ortalama.Text = AToDb.SelectField(tablename, "oratalama", "id_student", id);
                txt_puan.Text = AToDb.SelectField(tablename, "ball", "id_student", id);


                txt_alerji_tur1.Text = AToDb.SelectField(tablename, "alerji_turu", "id_student", id);
                txt_hasta_tur2.Text = AToDb.SelectField(tablename, "kronik_turu", "id_student", id);
                txt_puan.Text = AToDb.SelectField(tablename, "ball", "id_student", id);
                txt_rapor.Text = AToDb.SelectField(tablename, "health_report", "id_student", id);
                txt_why.Text = AToDb.SelectField(tablename, "exit_reason", "id_student", id);
                cmb_blood.SelectedValue = AToDb.SelectField(tablename, "bloodgrup_id", "id_student", id);
                //cmb_oda.SelectedValue = AToDb.SelectField(tablename, "room_id", "id_student", id);
                var bed = AToDb.SelectField(tablename, "bed_id", "id_student", id);
                var room = AToDb.SelectField("select room_id from bed where id=" + bed);
                var yurt = AToDb.SelectField("select yurt_id from room where id=" + room);
                cmb_yurt.SelectedValue = yurt;
                cmb_oda.SelectedValue = room;
                cmb_yatak.SelectedValue = bed;


                
                //dtp_enterdate.Value = Helper.ChangeDateFormat( AToDb.SelectField(tablename, "enter_date", "id_student", id));


                var yes1 = AToDb.SelectField(tablename, "alerji", "id_student", id);
                if (yes1 == "1")
                {
                    rbtn_yes1.Checked = true;
                }
                else
                {
                    rtbn_no1.Checked = true;
                }
                var yes2 = AToDb.SelectField(tablename, "kronik_hasta", "id_student", id);
                if (yes2 == "1")
                {
                    rbtn_yes2.Checked = true;
                }
                else
                {
                    rbtn_no2.Checked = true;
                }
                var yes3 = AToDb.SelectField(tablename, "sigara", "id_student", id);
                if (yes3 == "1")
                {
                    rbtn_yes3.Checked = true;
                }
                else
                {
                    rbtn_no3.Checked = true;
                }
                var kkayit = AToDb.SelectField(tablename, "kkayit", "id_student", id);
                 if( kkayit == "1")
                 {
                     checkBox1.Checked = true;
                 }
                 else
                 {
                     checkBox1.Checked = false;
                 }
            }
            else
            {
                Initialize();
                ClearAll();
            }
        }

        protected override void Set(int id1,string tablename)
        {
            button10.Enabled = false;
            string id = Convert.ToString(id1);
            txt_dosye_no.Text = AToDb.SelectField(tablename, "ID_student", "ID_student", id);
            txt_no.Text = AToDb.SelectField(tablename, "no", "ID_student", id);
            txt_donem.Text = AToDb.SelectDate();//AToDb.SelectField(tablename, "donem", "ID_student", id);
            //txt_donem.Text = AToDb.SelectField(tablename, "donem", "ID_student", id);
            if (AToDb.SelectField(tablename, "student_id", "ID_student", id).Length > 0)
            {

                dtp_enterdate.Text = AToDb.SelectField(tablename, "enter_date", "id_student", id);

                txt_name.Text = AToDb.SelectField(tablename, "name", "ID_student", id);
                txt_student_id.Text = AToDb.SelectField(tablename, "student_id", "ID_student", id);
                // MessageBox.Show(data1);
                maskedTextBox1.Text = Helper.ChangeDateFormat(AToDb.SelectField(tablename, "cast(date(birth_date) as char)", "ID_student", id)).ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);
                //dateTimePicker1.Value = Helper.ChangeDateFormat(AToDb.SelectField(tablename, "cast(date(birth_date) as char)", "ID_student", id));

                txt_birth_place.Text = AToDb.SelectField(tablename, "birth_place", "id_student", id);
                txt_phone_number.Text = AToDb.SelectField(tablename, "home_telephone", "id_student", id);
                txt_home_address.Text = AToDb.SelectField(tablename, "home_address", "id_student", id);
                cmb_nation.SelectedValue = AToDb.SelectField(tablename, "nation_id", "id_student", id);
                cmb_country.SelectedValue = AToDb.SelectField(tablename, "country_id", "id_student", id);
                string bolum = AToDb.SelectField(tablename, "bolum_id", "id_student", id);
                cmb_fakulty.SelectedValue =
                    AToDb.SelectField("select fakulty_id from bolum where id=" +
                                      bolum);
                cmb_bolum.SelectedValue = bolum; //aToDb.SelectField("onmaintable", "bolum_id", "id_student", id);
                cmb_cource.SelectedValue = AToDb.SelectField(tablename, "cource_id", "id_student", id);
                txt_passport.Text = AToDb.SelectField(tablename, "passport", "id_student", id);
                cmb_place.SelectedValue = AToDb.SelectField(tablename, "place_id", "id_student", id);
                cmb_sex.SelectedValue = AToDb.SelectField(tablename, "pol_id", "id_student", id);
                txt_dad_name.Text = AToDb.SelectField(tablename, "dad_name", "id_student", id);

                txt_dad_surname.Text = AToDb.SelectField(tablename, "dad_surname", "id_student", id);
                cmb_dad_profession.SelectedValue = AToDb.SelectField(tablename, "dad_profession", "id_student", id);
                txt_dad_phone.Text = AToDb.SelectField(tablename, "dad_workphone", "id_student", id);
                txt_dad_address.Text = AToDb.SelectField(tablename, "dad_workaddress", "id_student", id);
                txt_dad_zarplata.Text = AToDb.SelectField(tablename, "dad_income", "id_student", id);
                cmb_dad_valute.SelectedValue = AToDb.SelectField(tablename, "valute_idd", "id_student", id);
                cmb_dad_health.SelectedValue = AToDb.SelectField(tablename, "dad_health_id", "id_student", id);
                cmb_dad_handicap.SelectedValue = AToDb.SelectField(tablename, "dad_handicap_id", "id_student", id);

                txt_mom_name.Text = AToDb.SelectField(tablename, "mom_name", "id_student", id);
                txt_mom_surname.Text = AToDb.SelectField(tablename, "mom_surname", "id_student", id);
                cmb_mom_profession.SelectedValue = AToDb.SelectField(tablename, "mom_profession", "id_student", id);
                txt_mom_phone.Text = AToDb.SelectField(tablename, "mom_workphone", "id_student", id);
                txt_mom_address.Text = AToDb.SelectField(tablename, "mom_workaddress", "id_student", id);
                txt_mom_zarplata.Text = AToDb.SelectField(tablename, "mom_income", "id_student", id);
                cmb_mom_valute.SelectedValue = AToDb.SelectField(tablename, "valute_idm", "id_student", id);
                cmb_mom_health.SelectedValue = AToDb.SelectField(tablename, "mom_health_id", "id_student", id);
                cmb_mom_handicap.SelectedValue = AToDb.SelectField(tablename, "mom_handicap_id", "id_student", id);

                cmb_parent_state.SelectedValue = AToDb.SelectField(tablename, "parent_state", "id_student", id);
                cmb_count.SelectedValue = AToDb.SelectField(tablename, "studyfamilycount", "id_student", id);
                cmb_student_handicap.SelectedValue = AToDb.SelectField(tablename, "handicap_id", "id_student", id);

                txt_ortalama.Text = AToDb.SelectField(tablename, "oratalama", "id_student", id);
                txt_puan.Text = AToDb.SelectField(tablename, "ball", "id_student", id);


                txt_alerji_tur1.Text = AToDb.SelectField(tablename, "alerji_turu", "id_student", id);
                txt_hasta_tur2.Text = AToDb.SelectField(tablename, "kronik_turu", "id_student", id);
                txt_puan.Text = AToDb.SelectField(tablename, "ball", "id_student", id);
                txt_rapor.Text = AToDb.SelectField(tablename, "health_report", "id_student", id);
                txt_why.Text = AToDb.SelectField(tablename, "exit_reason", "id_student", id);
                cmb_blood.SelectedValue = AToDb.SelectField(tablename, "bloodgrup_id", "id_student", id);
                //cmb_oda.SelectedValue = AToDb.SelectField(tablename, "room_id", "id_student", id);
                var bed = AToDb.SelectField(tablename, "bed_id", "id_student", id);
                var room = AToDb.SelectField("select room_id from bed where id=" + bed);
                var yurt = AToDb.SelectField("select yurt_id from room where id=" + room);
                cmb_yurt.SelectedValue = yurt;
                cmb_oda.SelectedValue = room;
                cmb_yatak.SelectedValue = bed;
                var yes1 = AToDb.SelectField(tablename, "alerji", "id_student", id);

                //dtp_enterdate.Value = Helper.ChangeDateFormat(AToDb.SelectField(tablename, "enter_date", "id_student", id));


                if (yes1 == "1")
                {
                    rbtn_yes1.Checked = true;
                }
                else
                {
                    rtbn_no1.Checked = true;
                }
                var yes2 = AToDb.SelectField(tablename, "kronik_hasta", "id_student", id);
                if (yes2 == "1")
                {
                    rbtn_yes2.Checked = true;
                }
                else
                {
                    rbtn_no2.Checked = true;
                }
                var yes3 = AToDb.SelectField(tablename, "sigara", "id_student", id);
                if (yes3 == "1")
                {
                    rbtn_yes3.Checked = true;
                }
                else
                {
                    rbtn_no3.Checked = true;
                }
                var kkayit = AToDb.SelectField(tablename, "kkayit", "id_student", id);
                if (kkayit == "True")
                {
                    checkBox1.Checked = true;
                }
                else
                {
                    checkBox1.Checked = false;
                }
            }
            else
            {
                Initialize();
                ClearAll();
            }
        }

        protected override void Initialize()
        {
            Data.Clear();
            ClearAll();
            AToDb = new ConnectionToDb(Helper.ConnectionString);
            checkBox1.Checked = false;
            statusStrip1.Items[0].Text = "Kesin kayit olan ogrencilerin sayisi=" +AToDb.SelectField("select count(*) from kmaintable where pol_id="+pol);
            AToDb.AddItem(cmb_nation, "nation");
            AToDb.AddItem(cmb_country, "country");
            AToDb.AddItem(cmb_place, "place");
            AToDb.AddItem(cmb_fakulty, "fakulty");
            AToDb.AddItem(cmb_dad_handicap, "parenthandicap");
            AToDb.AddItem(cmb_mom_handicap, "parenthandicap");
            AToDb.AddItem(cmb_dad_profession, "profession");
            AToDb.AddItem(cmb_dad_valute, "valute");
            AToDb.AddItem(cmb_mom_profession, "profession");
            AToDb.AddItem(cmb_mom_valute, "valute");
            AToDb.AddItem(cmb_sex, "pol");
            AToDb.AddItem(cmb_dad_health, "health");
            AToDb.AddItem(cmb_mom_health, "health");
            AToDb.AddItem(cmb_parent_state, "parentstate");
            AToDb.AddItem(cmb_student_handicap, "studenthandicap");
            AToDb.AddItem(cmb_count, "kardes");
            //Donem = DateTime.Today.Year.ToString(CultureInfo.InvariantCulture) + "-" +
                    //DateTime.Today.AddYears(1).Year.ToString(CultureInfo.InvariantCulture);
            txt_donem.Text = AToDb.SelectDate();
            string temp = AToDb.SelectField("kmaintable", "ID_student", "max");
            txt_dosye_no.Text = Convert.ToString(Int32.Parse(temp) + 1);
            txt_no.Text = Convert.ToString(Convert.ToInt32(AToDb.SelectField("kmaintable", "no", "max", "pol_id", pol)) + 1);
            cmb_sex.SelectedValue = pol;
            cmb_sex.Enabled = false;
            txt_student_id.TextChanged += TextBox3TextChanged;
            //txt_student_id.Leave += TextBox3Leave;
            maskedTextBox1.Clear();
            //KKayit_Load(null,null);
        }

        protected override void ClearAll()
        {
            base.ClearAll();
            Data.Clear();
            txt_student_id.Clear();
            txt_alerji_tur1.Clear();
            txt_hasta_tur2.Clear();
            //txt_why.Clear();
            txt_rapor.Clear();
            txt_puan.Clear();
        }

        public override int AddData()
        {
            Data.Clear();
            int ball = 0;

            string studentNumber = txt_student_id.Text;
            string name = txt_name.Text;
            string pol = Convert.ToString(cmb_sex.SelectedValue);
            string birthday = String.Empty;
            if (maskedTextBox1.Text.Contains('.'))
            {
                birthday=Helper.ChangeDateFormat1(maskedTextBox1.Text, '.').ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);//dateTimePicker1.Value.ToString("yyyy-MM-dd",CultureInfo.InvariantCulture);
            }
            else if (maskedTextBox1.Text.Contains(','))
            {
                birthday = Helper.ChangeDateFormat1(maskedTextBox1.Text, ',').ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
            }
            string birthPlace = txt_birth_place.Text;
            string homephone = txt_phone_number.Text;
            string homeaddress = txt_home_address.Text;
            string country = Convert.ToString(cmb_country.SelectedValue);
            string nation = Convert.ToString(cmb_nation.SelectedValue);
            string passport = txt_passport.Text;
            string bolum = Convert.ToString(cmb_bolum.SelectedValue);


            string handicap = Convert.ToString(cmb_student_handicap.SelectedValue);
            string ortalama = txt_ortalama.Text;
            string place = Convert.ToString(cmb_place.SelectedValue);
            string cource = Convert.ToString(cmb_cource.SelectedValue);
            string dhandicap = Convert.ToString(cmb_dad_handicap.SelectedValue);
            string mhandicap = Convert.ToString(cmb_mom_handicap.SelectedValue);
            string parentstate = Convert.ToString(cmb_parent_state.SelectedValue);
            string kardes = Convert.ToString(cmb_count.SelectedValue);



            string dname = txt_dad_name.Text;
            string dsurname = txt_dad_surname.Text;
            string dprofession = Convert.ToString(cmb_dad_profession.SelectedValue);
            string dworkaddress = txt_dad_address.Text;
            string dworkphone = txt_dad_phone.Text;
            string dincome = txt_dad_zarplata.Text;
            string dvalute = Convert.ToString(cmb_dad_valute.SelectedValue);
            string dhealth = Convert.ToString(cmb_dad_health.SelectedValue);



            string mname = txt_mom_name.Text;
            string msurname = txt_mom_surname.Text;
            string mprofession = Convert.ToString(cmb_mom_profession.SelectedValue);
            string mworkaddress = txt_mom_address.Text;
            string mworkphone = txt_mom_phone.Text;
            string mincome = txt_mom_zarplata.Text;
            string mvalute = Convert.ToString(cmb_mom_valute.SelectedValue);
            string mhealth = Convert.ToString(cmb_mom_health.SelectedValue);

            string puanortalama =
             AToDb.SelectField("SELECT id FROM puanortalama WHERE max_value>=" + ortalama + " and min_value<=" +
                                 ortalama);

            var tableName = new string[2,8];
            tableName[0, 0] = "cource";
            tableName[1, 0] = cource;
            tableName[0, 1] = "place";
            tableName[1, 1] = place;
            tableName[0, 2] = "parentstate";
            tableName[1, 2] = parentstate;
            tableName[0, 3] = "studenthandicap";
            tableName[1, 3] = handicap;
            tableName[0, 4] = "parenthandicap";
            tableName[1, 4] = dhandicap;
            tableName[0, 5] = "parenthandicap";
            tableName[1, 5] = mhandicap;
            tableName[0, 6] = "kardes";
            tableName[1, 6] = kardes;
            tableName[0, 7] = "puanortalama";
            tableName[1, 7] = puanortalama;
            ball = AToDb.SelectTable(tableName);
            txt_puan.Text = Convert.ToString(ball);
            string blood = Convert.ToString(cmb_blood.SelectedValue);
            string bed = Convert.ToString(cmb_yatak.SelectedValue);
            string enterdate = dtp_enterdate.Value.ToString("yyyy-MM-dd",CultureInfo.InvariantCulture);
            string exit = dtp_exitdate.Value.ToString("yyyy-MM-dd",CultureInfo.InvariantCulture);
            string reason = txt_why.Text;
            string sig = Convert.ToString(_sigara);
            string healthReport = txt_rapor.Text;
            string date = DateTime.Now.ToString("yyyy-MM-dd"); //regdate 38
            string kkayit="0";
            kkayit = checkBox1.Checked ? "1" : "0";



            Data.Add(Donem); //Donem 1
            Data.Add(studentNumber); //Student_id 2
            Data.Add(name); //Name 3
            Data.Add(pol); //Pol 4
            Data.Add(birthday); //Birth_date 5
            Data.Add(birthPlace); //Birth_place 6
            Data.Add(homephone); //HomePhone 7
            Data.Add(homeaddress); //HomeAddress 8
            Data.Add(country); //country_id 9
            Data.Add(nation); //nation_id 10
            Data.Add(passport); //passport 11
            Data.Add(handicap); //Handicap 12
            Data.Add(cource); //cource 13
            Data.Add(bolum); //bolum 14
            Data.Add(ortalama); //ortalama 15
            Data.Add(place); //place 16
            Data.Add(dname); //name 17
            Data.Add(dsurname); //surname 18
            Data.Add(dprofession); //profession19
            Data.Add(dworkaddress); //workadres 20
            Data.Add(dworkphone); //workphone 21
            Data.Add(dincome); //income 22
            Data.Add(dvalute); //valute 23 
            Data.Add(dhandicap); //handicap 24
            Data.Add(dhealth); //health 25
            Data.Add(mname); //name 26
            Data.Add(msurname); //surname 27
            Data.Add(mprofession); //profession 28
            Data.Add(mworkaddress); //workaddress 29
            Data.Add(mworkphone); //workphone 30
            Data.Add(mincome); //income 31
            Data.Add(mvalute); //valute 32
            Data.Add(mhandicap); //handicap 33
            Data.Add(mhealth); //health 34
            Data.Add(parentstate); //parentstate 35
            Data.Add(kardes); //kardes 36
            Data.Add(date); //regdate 37
            Data.Add(Convert.ToString(_hasta)); //kronik_hasta 38
            Data.Add(_hastaDesc); //kronik_turu 39
            Data.Add(Convert.ToString(_alerji)); //alerji 40
            Data.Add(_alerjiDesc); //alerji_turu 41
            Data.Add(blood); //bloodgrup_id 42
            Data.Add(bed); //bed_id 43
            Data.Add(enterdate); //enter_date 44
            Data.Add(exit); //exit_date 45
            Data.Add(sig); //sigara 45
            Data.Add(reason); //exit_reason 46
            Data.Add(healthReport); //health_report 47
            //Data.Add(Convert.ToString(ball)); //ball 48
            Data.Add(kkayit); //dosye_no 48
            Data.Add(txt_dosye_no.Text);
            Data.Add(txt_no.Text);
            return ball;

        }

        protected  void SetBookmark(string[] bookmarkname, string[] value,string path)
        {
            object oMissing = Missing.Value;
            Microsoft.Office.Interop.Word._Application oWord;
            Microsoft.Office.Interop.Word._Document oDoc;
            oWord = new Microsoft.Office.Interop.Word.Application();
            object oTemplate = path;
            oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);
            oWord.Visible = true;
            for (int i = 0; i < bookmarkname.Length; i++)
            {
                Object bookmarkNameObj = bookmarkname[i];
                Microsoft.Office.Interop.Word.Range bookmarkRange = null;
                bookmarkRange = oDoc.Bookmarks.get_Item(ref bookmarkNameObj).Range;
                bookmarkRange.InsertAfter(value[i]);
            }
        }

        #endregion

        #region Form

        private void KKayit_Load(object sender, System.EventArgs e)
        {
            _alerji = 0;
            _hasta = 0;
            menuStrip1.Visible = false;
            AToDb.AddItem(cmb_blood, "blood");
            AToDb.AddItem(cmb_yurt, "yurtdef");
            txt_why.Text = "Yok";
            if (id.Length>0)
                Set(id,"kmaintable");
            button10.Focus();
            
            //aToDb.AddItem(cmb_yatak, "yatak");
        }

        #endregion

        #region TextBox

        protected override void TextBox3Leave(object sender, EventArgs e)
        {
            if (txt_student_id.Text.Length > 0)
            {
                Data.Clear();
                if (txt_dosye_no.Text == Convert.ToString(Int32.Parse(AToDb.SelectField("select max(id_student) from kmaintable")) + 1))
                {
                    string t =
                        AToDb.SelectField("select id_student from kmaintable where student_id='" + txt_student_id.Text +
                                          "'");
                    if (t != "0")
                    {
                        MessageBox.Show("Бул студент каттоодон откон");
                        ClearAll();
                        Initialize();
                        txt_student_id.Focus();
                        return;
                    }
                    t =
                        AToDb.SelectField("select id_student from onmaintable where student_id='" + txt_student_id.Text +
                                          "' and res=1");
                    if (t == "0")
                    {
                        if (
                            MessageBox.Show("Бул студент катто тизмесинде жок", "Кулактандыруу", MessageBoxButtons.OK) ==
                            DialogResult.OK)
                        {
                            txt_student_id.Clear();
                            txt_student_id.Focus();
                            Initialize();
                            return;
                        }
                    }
                    string ort = AToDb.SelectField("onmaintable", "oratalama", "student_id", txt_student_id.Text, "res","1");
                    if (ort != "")
                    {
                        if (Convert.ToDouble(ort) > 2.5)
                        {
                            label18.Text = "Burs aliyour";
                            label18.ForeColor = Color.Chartreuse;
                        }
                        else
                        {
                            label18.Text = "Burs almiyour";
                            label18.ForeColor = Color.Crimson;
                        }
                    }
                    else
                    {
                        ort = "0";
                    }

                    string bolum;
                    txt_ortalama.Text = ort;
                   // var ceza = AToDb.SelectTableCeza(txt_student_id.Text);
                    //string puan = ceza != "" ? ceza : "0";
                    //txt_ceza.Text = puan;

                    txt_puan.Text = AToDb.SelectField("onmaintable", "ball", "student_id", txt_student_id.Text, "res",
                                                      "1");
                    txt_name.Text = AToDb.SelectField("onmaintable", "name", "student_id",
                                                      "'" + txt_student_id.Text + "'",
                                                      "res", "1");

                    maskedTextBox1.Text =
                        Helper.ChangeDateFormat(AToDb.SelectField("onmaintable", "cast(date(birth_date) as char)", "student_id",
                                                             "'" + txt_student_id.Text + "'", "res", "1")).ToString("dd.MM.yyyy",CultureInfo.InvariantCulture);

                    txt_birth_place.Text = AToDb.SelectField("onmaintable", "birth_place", "student_id",
                                                             "'" + txt_student_id.Text + "'", "res", "1");
                    txt_phone_number.Text = AToDb.SelectField("onmaintable", "home_telephone", "student_id",
                                                              "'" + txt_student_id.Text + "'", "res", "1");
                    txt_home_address.Text = AToDb.SelectField("onmaintable", "home_address", "student_id",
                                                              "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_nation.SelectedValue = AToDb.SelectField("onmaintable", "nation_id", "student_id",
                                                                 "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_country.SelectedValue = AToDb.SelectField("onmaintable", "country_id", "student_id",
                                                                  "'" + txt_student_id.Text + "'", "res", "1");
                    bolum = AToDb.SelectField("onmaintable", "bolum_id", "student_id", "'" + txt_student_id.Text + "'",
                                              "res", "1");
                    cmb_fakulty.SelectedValue =
                        AToDb.SelectField("select fakulty_id from bolum where id=" +
                                          bolum);
                    cmb_bolum.SelectedValue = bolum;
                    //aToDb.SelectField("onmaintable", "bolum_id", "student_id", "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_cource.SelectedValue = AToDb.SelectField("onmaintable", "cource_id", "student_id",
                                                                 "'" + txt_student_id.Text + "'", "res", "1");
                    txt_passport.Text = AToDb.SelectField("onmaintable", "passport", "student_id",
                                                          "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_place.SelectedValue = AToDb.SelectField("onmaintable", "place_id", "student_id",
                                                                "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_sex.SelectedValue = AToDb.SelectField("onmaintable", "pol_id", "student_id",
                                                              "'" + txt_student_id.Text + "'", "res", "1");
                    txt_dad_name.Text = AToDb.SelectField("onmaintable", "dad_name", "student_id",
                                                          "'" + txt_student_id.Text + "'", "res", "1");

                    txt_dad_surname.Text = AToDb.SelectField("onmaintable", "dad_surname", "student_id",
                                                             "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_dad_profession.SelectedValue = AToDb.SelectField("onmaintable", "dad_profession", "student_id",
                                                                         "'" + txt_student_id.Text + "'", "res", "1");
                    txt_dad_phone.Text = AToDb.SelectField("onmaintable", "dad_workphone", "student_id",
                                                           "'" + txt_student_id.Text + "'", "res", "1");
                    txt_dad_address.Text = AToDb.SelectField("onmaintable", "dad_workaddress", "student_id",
                                                             "'" + txt_student_id.Text + "'", "res", "1");
                    txt_dad_zarplata.Text = AToDb.SelectField("onmaintable", "dad_income", "student_id",
                                                              "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_dad_valute.SelectedValue = AToDb.SelectField("onmaintable", "valute_idd", "student_id",
                                                                     "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_dad_health.SelectedValue = AToDb.SelectField("onmaintable", "dad_health_id", "student_id",
                                                                     "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_dad_handicap.SelectedValue = AToDb.SelectField("onmaintable", "dad_handicap_id", "student_id",
                                                                       "'" + txt_student_id.Text + "'", "res", "1");

                    txt_mom_name.Text = AToDb.SelectField("onmaintable", "mom_name", "student_id",
                                                          "'" + txt_student_id.Text + "'", "res", "1");
                    txt_mom_surname.Text = AToDb.SelectField("onmaintable", "mom_surname", "student_id",
                                                             "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_mom_profession.SelectedValue = AToDb.SelectField("onmaintable", "mom_profession", "student_id",
                                                                         "'" + txt_student_id.Text + "'", "res", "1");
                    txt_mom_phone.Text = AToDb.SelectField("onmaintable", "mom_workphone", "student_id",
                                                           "'" + txt_student_id.Text + "'", "res", "1");
                    txt_mom_address.Text = AToDb.SelectField("onmaintable", "mom_workaddress", "student_id",
                                                             "'" + txt_student_id.Text + "'", "res", "1");
                    txt_mom_zarplata.Text = AToDb.SelectField("onmaintable", "mom_income", "student_id",
                                                              "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_mom_valute.SelectedValue = AToDb.SelectField("onmaintable", "valute_idm", "student_id",
                                                                     "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_mom_health.SelectedValue = AToDb.SelectField("onmaintable", "mom_health_id", "student_id",
                                                                     "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_mom_handicap.SelectedValue = AToDb.SelectField("onmaintable", "mom_handicap_id", "student_id",
                                                                       "'" + txt_student_id.Text + "'", "res", "1");

                    cmb_parent_state.SelectedValue = AToDb.SelectField("onmaintable", "parent_state", "student_id",
                                                                       "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_count.SelectedValue = AToDb.SelectField("onmaintable", "studyfamilycount", "student_id",
                                                                "'" + txt_student_id.Text + "'", "res", "1");
                    cmb_student_handicap.SelectedValue = AToDb.SelectField("onmaintable", "handicap_id", "student_id",
                                                                           "'" + txt_student_id.Text + "'", "res", "1");
                }
                else
                {
                    return;
                }
            }
        }

        private void txt_hasta_tur2_Leave(object sender, EventArgs e)
        {
            _hastaDesc = txt_hasta_tur2.Text.Length > 0 ? txt_hasta_tur2.Text : "Yok";
        }

        private void txt_alerji_tur1_Leave(object sender, EventArgs e)
        {
            _alerjiDesc = txt_alerji_tur1.Text.Length > 0 ? txt_alerji_tur1.Text : "Yok";
        }

        #endregion

        #region RadioButton

        private void rbtn_yes_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtn_yes1.Checked)
            {
                _alerji = 1;
                txt_alerji_tur1.Enabled = true;
            }
        }

        private void rtbn_yok_CheckedChanged(object sender, EventArgs e)
        {
            if (rtbn_no1.Checked)
            {
                _alerji = 0;
                txt_alerji_tur1.Enabled = false;
            }
        }

        private void rbtn_yes2_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtn_yes2.Checked)
            {
                _hasta = 1;
                txt_hasta_tur2.Enabled = true;
            }
        }

        private void rbtn_no2_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtn_no2.Checked)
            {
                _hasta = 0;
                txt_hasta_tur2.Enabled = false;
            }
        }

        private void rbtn_no3_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtn_no3.Checked)
            {
                _sigara = 0;
            }
        }

        private void rbtn_yes3_CheckedChanged(object sender, EventArgs e)
        {
            if (rbtn_yes3.Checked)
            {
                _sigara = 1;
            }
        }

        #endregion   

        #region ComboBox

        private void cmb_yurt_SelectedValueChanged(object sender, EventArgs e)
        {
            Type t = typeof (Int32);
            if (cmb_yurt.SelectedValue.GetType() == t)
            {
                AToDb.AddItem(cmb_oda, "room", "yurt_id","pol_id", Convert.ToInt32(cmb_yurt.SelectedValue),pol);
                if (cmb_oda.SelectedValue == null)
                {
                    cmb_yatak.DataSource = null;
                }
            }
        }

        private void cmb_oda_SelectedValueChanged(object sender, EventArgs e)
        {
            Type t = typeof (Int32);
            if (cmb_oda.SelectedValue != null)
            {
                if (cmb_oda.SelectedValue.GetType() == t)
                {
                    int a = Convert.ToInt32(cmb_oda.SelectedValue);
                    AToDb.AddItem(cmb_yatak, "bed", "room_id", a);
                }
            }

        }

        #endregion

        #region Button

        protected override void Button10Click(object sender, EventArgs e)
        {
            AddData();
            foreach (string temp in AToDb.SelectField("kmaintable", "bed_id"))
            {
                if (temp == AToDb.SelectField("kmaintable", "bed_id", "student_id", txt_student_id.Text)) 
                    break;
                if (temp == Convert.ToString(cmb_yatak.SelectedValue))
                {
                    MessageBox.Show("Бул керебет бош эмес");
                    return;
                }
            }
            //int i = 0, j = 0;
            /*foreach (var a in Data)
            {
                i++;
                if (a.Length > 0)
                {
                    j++;
                }
                else
                {
                    MessageBox.Show(Helper.Error(j) + " киргизгиле");
                    return;
                }
            }
            if (i == j)
            {
                MessageBox.Show("Баардык талаалар киргизилди");
            }*/
            //AToDb.UpdateMainTable("kkayit", "1", "student_id", Data[1]);
            AToDb.InsertIntoKMainTable(Data);
            MessageBox.Show("Kesin kayit oldu");
            //ClearAll();
            //Initialize();
        }


        protected override void Button3Click(object sender, EventArgs e)
        {
            min = Int32.Parse(AToDb.SelectField("select min(id_student) from kmaintable where pol_id=" + pol));
            Set(min,"kmaintable");
            button4.Enabled = false;
            button5.Enabled = true;
            button10.Enabled = false;
        }

        protected override void Button4Click(object sender, EventArgs e)
        {
            prev = Int32.Parse(AToDb.SelectField("select id_student from kmaintable where no=" + txt_no.Text + "-1 and pol_id=" + pol));
            if (prev != 0)
            {
                if (next <= Int32.Parse(AToDb.SelectField("select max(id_student) from kmaintable where pol_id=" + pol) + 1))
                {
                    button5.Enabled = true;
                }
                Set(prev,"kmaintable");
            }
        }

        protected override void Button5Click(object sender, EventArgs e)
        {
            next = Int32.Parse(AToDb.SelectField("select id_student from kmaintable where no=" + txt_no.Text + "+1 and pol_id=" + pol));
            if (next != 0)
            {
                if (next <= Int32.Parse(AToDb.SelectField("select max(id_student) from kmaintable where pol_id=" + pol)))
                {
                    Set(next,"kmaintable");
                }
                if (prev != 1)
                {
                    button4.Enabled = true;
                }
            }
            else
            {
                button5.Enabled = false;
            }
        }

        protected override void Button6Click(object sender, EventArgs e)
        {
            max = Int32.Parse(AToDb.SelectField("select max(id_student) from kmaintable where pol_id=" + pol));
            Set(max,"kmaintable");
            button5.Enabled = false;
            button4.Enabled = true;
            button10.Enabled = false;
            //textBox3_Leave(null, null);
        }

        protected override void Button7Click(object sender, EventArgs e)
        {
            base.ClearAll();
            ClearAll();
            base.Initialize();
            Initialize();
            txt_student_id.Leave += TextBox3Leave;
            cmb_yurt_SelectedValueChanged(null,null);
            button10.Enabled = true;
            button4.Enabled = true;
        }

        protected override void Button9Click(object sender, EventArgs e)
        {
            AddData();
            foreach (var temp in AToDb.SelectField("kmaintable", "bed_id","ID_student",Int32.Parse(Data[49])))
            {
                if (temp == AToDb.SelectField("kmaintable", "bed_id", "student_id", txt_student_id.Text))
                {
                    goto L;
                }
                if (temp == Convert.ToString(cmb_yatak.SelectedValue))
                {
                    MessageBox.Show("Бул керебет бош эмес");
                    return;
                }
            }
            L://int i = 0, j = 1;
            /*foreach (var a in Data)
            {
                i++;
                if (a.Length > 0)
                {
                    j++;
                }
                else
                {
                    MessageBox.Show(Helper.Error(j) + " киргизгиле");
                    return;
                }
                if (i == j)
                {
                    MessageBox.Show("Баардык талаалар киргизилди");
                }
            }*/
            AToDb.UpdateKMainTable(Data, txt_dosye_no.Text);
            MessageBox.Show("Duzenlendi");
            //ClearAll();
            //Initialize();
        }

        #endregion

        #region Menu
        private void onKayitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Kayit f=new Kayit();
            f.Show();
        }

        private void ilkKayitToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Button3Click(null,null);
        }

        private void oncekiKayitToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Button4Click(null,null);
        }

        private void sonrakiKayitToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Button5Click(null,null);
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            Button6Click(null,null);
        }

        private void kayitEkleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Button7Click(null,null);
        }

        private void kayitSilToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Button8Click(null,null);
        }

        private void duzenleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Button9Click(null,null);
        }

        private void kaydetToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Button10Click(null,null);
        }

        private void iptalEtToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Button11Click(null,null);
        }

        private void aramaFormuToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            SearchForm f=new SearchForm();
            f.Load += f_hide;
            f.FormClosed += f_close;
            f.ShowDialog();
        }

        private void f_close(object sender, FormClosedEventArgs e)
        {
            Close();
        }

        private void f_hide(object sender, EventArgs e)
        {
            Hide();
        }


        private void kesinKayitFormuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string ID = txt_no.Text;
            if (txt_student_id.Text.Length > 0 && txt_passport.Text.Length > 0)
            {
                string regdate = AToDb.SelectField("onmaintable", "cast(date(regdate) as char)", "student_id",
                                                   txt_student_id.Text);
                string room =
                    AToDb.SelectField("select a.description from room a,bed b where b.room_id=a.id and b.id=" +
                                      Convert.ToString(cmb_yatak.SelectedValue));
                string yurt =
                    AToDb.SelectField("select description from yurtdef where id=" +
                                      Convert.ToString(cmb_yurt.SelectedValue));
                string bed =
                    AToDb.SelectField("select a.description from bed a where a.id=" +
                                      Convert.ToString(cmb_yatak.SelectedValue));
                string date = maskedTextBox1.Text;
                string bolum =
                    AToDb.SelectField("select description from bolum where id=" +
                                      Convert.ToString(cmb_bolum.SelectedValue));
                string fakulty =
                    AToDb.SelectField("select b.description from bolum a,fakulty b where a.fakulty_id=b.id and a.id=" +
                                      Convert.ToString(cmb_bolum.SelectedValue));
                string cource =
                    AToDb.SelectField("select description from cource where id=" +
                                      Convert.ToString(cmb_cource.SelectedValue));
                string country =
                    AToDb.SelectField("select description from country where id=" +
                                      Convert.ToString(cmb_country.SelectedValue));
                string nation =
                    AToDb.SelectField("select description from nation where id=" +
                                      Convert.ToString(cmb_nation.SelectedValue));
                string h1 =
                    AToDb.SelectField(
                        "select a.description from health a,onmaintable b where b.dad_health_id=a.id and a.id=" +
                        Convert.ToString(cmb_dad_health.SelectedValue));
                string h2 =
                    AToDb.SelectField(
                        "select a.description from health a,onmaintable b where b.mom_health_id=a.id and a.id=" +
                        Convert.ToString(cmb_mom_health.SelectedValue));
                string address = txt_home_address.Text;
                string kardes =
                    AToDb.SelectField(
                        "select a.description from kardes a,onmaintable b where b.studyfamilycount=a.id and a.id=" +
                        Convert.ToString(cmb_count.SelectedValue));
                string p1 =
                    AToDb.SelectField(
                        "select a.description from profession a,onmaintable b where b.dad_profession=a.id and a.id=" +
                        Convert.ToString(cmb_dad_profession.SelectedValue));
                string p2 =
                    AToDb.SelectField(
                        "select a.description from profession a,onmaintable b where b.mom_profession=a.id and a.id=" +
                        Convert.ToString(cmb_mom_profession.SelectedValue));
                string pp1 = txt_mom_phone.Text;
                string pp2 = txt_dad_phone.Text;
                string phone = txt_phone_number.Text;
                string a1 = txt_dad_address.Text;
                string a2 = txt_mom_address.Text;
                string hasta, alerji;
                if (
                    AToDb.SelectField("select kronik_hasta from kmaintable where student_id='" + txt_student_id.Text +
                                      "'") == "0")
                    hasta = "yok";
                else
                    hasta = "var";
                if (AToDb.SelectField("select alerji from kmaintable where student_id='" + txt_student_id.Text + "'") ==
                    "0")
                    alerji = "yok";
                else
                    alerji = "var";
                string hastat = txt_hasta_tur2.Text, alertur = txt_alerji_tur1.Text;
                string rapor = txt_rapor.Text;
                string[] bk =
                    {
                        "ID_student", "regdate", "student_id", "room", "bed", "name", "birth_place", "birth_date"
                        , "fakulty", "bolum", "cource", "country", "nation", "dhealth", "mhealth", "address",
                        "dprof", "mprof", "dwtel", "mwtel", "tel", "dwadr", "mwadr",
                        "cronic", "cronic_type", "alerji", "alerji_type", "rapor","yurt"
                    };
                string[] val =
                    {
                        ID, regdate, txt_student_id.Text, room, bed, txt_name.Text,
                        txt_birth_place.Text, date, fakulty, bolum, cource, country, nation, h1, h2, address, p1
                        , p2, pp1, pp2, phone, a1, a2, hasta, hastat, alerji, alertur, rapor,yurt
                    };
                    List<ReportParameter> par = bk.Select((t, i) => new ReportParameter(t, val[i])).ToList();
                    ReportForm f = new ReportForm();
                    f.reportViewer1.ProcessingMode = ProcessingMode.Local;
                    f.reportViewer1.LocalReport.ReportPath = "ReportTemplate/KKayit.rdlc";
                    f.reportViewer1.LocalReport.SetParameters(par);
                    f.ShowDialog();
            }
            else
            {
                MessageBox.Show("Студентти берилиштер базасынан тандагыла");
            }
        }

        private void kizYurduToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void erkekYurduToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
        #endregion

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }
        private void txt_ceza_TextChanged(object sender, EventArgs e)
        {

        }

        protected override void button2_Click(object sender, EventArgs e)
        {
            if (txt_student_id.Text != "")
            {
                Ceza f = new Ceza(txt_student_id.Text);
                f.FormClosed += FormClose;
                f.ShowDialog();
                f.Dispose();
            }
            else
            {
                MessageBox.Show("Студенттик номерди киргизгиле!!!");
                txt_student_id.Focus();
            }
        }

        private void FormClose(object sender, FormClosedEventArgs e)
        {
            lbl_ceza.Text = AToDb.SelectField("select sum(a.ball) from ceza a,disiplin b where a.ID=b.ceza and b.student_id like('" +txt_student_id.Text+"')");
            txt_puan.Text = AToDb.SelectField("select ball from kmaintable where student_id like('"+txt_student_id.Text+"') ");
        }

        protected override void Button8Click(object sender, EventArgs e)
        {
            int no = Int32.Parse(txt_no.Text);
            if (MessageBox.Show("Kayiti silmek istiyourmusunuz???", "Dikkat", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                AToDb.DeleteTable("kmaintable", "student_id", txt_student_id.Text);
                AToDb.Call("call autodeckk("+no+","+pol+")");
                Button5Click(null,null);
                Initialize();
            }
        }

        private void raporlamaToolStripMenuItem1_Click(object sender, EventArgs e)
        {

        }


        private void yurtUcretFormuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string bolum =AToDb.SelectField("select description from bolum where id=" +Convert.ToString(cmb_bolum.SelectedValue));
            string fakulty =AToDb.SelectField("select b.description from bolum a,fakulty b where a.fakulty_id=b.id and a.id=" +Convert.ToString(cmb_bolum.SelectedValue));
            string cource =AToDb.SelectField("select description from cource where id=" +Convert.ToString(cmb_cource.SelectedValue));
            string room =AToDb.SelectField("select a.description from room a,bed b where b.room_id=a.id and b.id=" +Convert.ToString(cmb_yatak.SelectedValue));
            string yurt =AToDb.SelectField("select description from yurtdef where id=" +Convert.ToString(cmb_yurt.SelectedValue));
            string bed =AToDb.SelectField("select a.description from bed a where a.id=" +Convert.ToString(cmb_yatak.SelectedValue));
            string donem = txt_donem.Text;
            string name = txt_name.Text;
            string now = DateTime.Now.ToString("dd.MM.yyyy",CultureInfo.InvariantCulture);
            string[] param = {"now","donem", "name", "yurt", "room", "bed", "fakulty", "bolum", "cource" };
            string[] val = {now,donem, name, yurt, room, bed, fakulty, bolum, cource };
            string path = System.Windows.Forms.Application.StartupPath + "\\ReportTemplate\\1234.dot";
            SetBookmark(param,val,path);
            //List<ReportParameter> par = param.Select((t, i) => new ReportParameter(t, val[i])).ToList();
            //ReportForm f = new ReportForm();
            //f.reportViewer1.ProcessingMode = ProcessingMode.Local;
            //f.reportViewer1.LocalReport.ReportPath = "ReportTemplate/Ucret.rdlc";
            //f.reportViewer1.LocalReport.SetParameters(par);
            //f.ShowDialog();
        }

        private void taahhutnameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string name = txt_name.Text;
            string now = DateTime.Now.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);
            string[] param = { "date", "name1","name2" };
            string path = System.Windows.Forms.Application.StartupPath + "\\ReportTemplate\\temp.dot";
            string[] val = { now, name,name};
            SetBookmark(param,val,path);
            /*List<ReportParameter> par = param.Select((t, i) => new ReportParameter(t, val[i])).ToList();
            List<ReportParameter> aList=new List<ReportParameter>();
            ReportForm f = new ReportForm();
            f.reportViewer1.ProcessingMode = ProcessingMode.Local;
            f.reportViewer1.LocalReport.ReportPath = "ReportTemplate/Taahhutname.rdlc";
            f.reportViewer1.LocalReport.SetParameters(par);
            f.ShowDialog();*/
        }

        private void tabPage1_Click(object sender, EventArgs e)
        {

        }
    }
}
